package com.bigtomato.controller;

import com.youthfilmic.yuejian.dao.ApplicationDao;
import com.youthfilmic.yuejian.dao.TextInfoDao;
import com.youthfilmic.yuejian.dao.UserDao;
import com.youthfilmic.yuejian.domain.TextInfo;
import com.youthfilmic.yuejian.domain.User;
import com.youthfilmic.yuejian.weixin.core.TokenSystem;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.UUID;

@Controller
public class Test {
	@Resource
	private UserDao userDao;
	@Resource
	private TextInfoDao textInfoDao;
	@Resource
	private ApplicationDao applicationDao;
	
	@RequestMapping("/test")
	public String showPage(
			@RequestParam(value="id" , required = false) Long id,
			HttpSession session , Model model){
		//这里是作弊登录
		Long i = 19L;
		if (id != null) i = id;
		session.setAttribute("userId", i);

		TextInfo ii = new TextInfo();
		ii.setText("hhakhdfkjadhsfkja");
		textInfoDao.save(ii);

		model.addAttribute("token", TokenSystem.getTokenValue());

		return "test";
	}

	@RequestMapping("/main")
	public String showPage1(){
		return "test";
	}

	@RequestMapping("/main/1")
	public String showPage2(){
		return "test";
	}

	@RequestMapping("/main/1/2")
	public String showPage3(){
		return "test";
	}


	public static void main(String args[]){
		UUID uuid = UUID.randomUUID();
		String str = uuid.toString();
		System.out.println(str);
	}
}
